
package com.csun.cmny.provider.device.watch.entity;


    /// <summary>
    ///  上行心率/步数/睡眠数据包
    ///  关联 013
    ///  Up heart rate / step / sleep packet
    /// Association confirmation command FunCode: 013
    /// </summary>
    public class C012
    {
        /// <summary>
        /// 数据起封包 @B#@ 
        /// Start Fixed value :@B#@ 
        /// </summary>
        public String HeadCode = "@B#@";
        /// <summary>
        /// 协议版本号
        /// Protocol version number
        /// </summary>
        public String Protocol = null;
        /// <summary>
        /// 功能代码识别
        /// Function code
        /// </summary>
        public final String FunCode = "012";
        /// <summary>
        /// 国际移动设备身份码
        /// International Mobile Equipment Identity
        /// </summary>
        public String IMEI = null;
        /// <summary>
        /// 国际移动用户识别码
        /// International Mobile Subscriber Identification Number
        /// </summary>
        public String IMSI = null;
        /// <summary>
        /// 佩戴状态 （0:未佩戴 ;1:已佩戴）
        /// Terminal wear state  (0: is not worn; 1: is worn)
        /// </summary>
        public int WearState =0;
        /// <summary>
        /// 剩余电量百分比（range:1-100）
        /// Percentage of residual electricity (range:1-100)
        /// </summary>
        public int Power  =0;
        /// <summary>
        /// 心率值
        /// Heart rate value
        /// </summary>
        public int Bat  =0;
        /// <summary>
        /// 步数
        /// The number of walking
        /// </summary>
        public int BuShu  =0;

        /// <summary>
        /// 睡眠开始时间&睡眠结束时间&深睡眠时间&浅睡眠时间。
        /// 此数据每天发送一次，在起床以后发送，没有数据时&之间都为空
        /// The start time of sleep & the end of sleep & deep sleep time & shallow sleep time.
        /// This data is sent once a day, sent after getting up, and no data is empty.
        /// </summary>
        public String Sleep = null;
        /// <summary>
        /// 终端当前时间(年月日时分秒) yyyyMMddHHmmss
        /// The terminal current time ( format:yyyyMMddHHmmss)
        /// </summary>
        public String TerminalTime = null;

        /// <summary>
        /// 结尾封包 @E#@
        /// End packet @E#@
        /// </summary>
        public String FootCode = "@E#@";




        /// <summary>
        /// 初始化模型
        /// @B#@|01|012|111112222233333|8888888888888888|1|32|89|980|201612162330&201612170730&0210&0550|20160715162252|@E#@
        /// </summary>
        /// <param name="cmdStr">命令代码</param>
        public C012(String cmdStr)
        {

        	String[] data = cmdStr.split("\\|");
            int dataLength = data.length;
            //正确格式下 最小长度为12
            if (dataLength ==12 && "@B#@".equals(data[0]) && FunCode.equals(data[2]))
            {
                HeadCode = data[0];
                Protocol = data[1];
                IMEI = data[3];
                IMSI = data[4];
                WearState = Integer.parseInt(data[5]);
                Power =Integer.parseInt(data[6]);
                Bat = Integer.parseInt(data[7]);
                BuShu = Integer.parseInt(data[8]);
                Sleep = data[9];
                TerminalTime = data[10];
                FootCode = data[11];
            }
        }

        public  String ToString()
        {
        	String rString = HeadCode + "|";
            rString += Protocol + "|";
            rString += FunCode + "|";
            rString += IMEI + "|";
            rString += IMSI + "|";
            rString += WearState + "|";
            rString += Power + "|";
            rString += Bat + "|";
            rString += BuShu + "|";
            rString += Sleep + "|";
            rString += TerminalTime + "|";
            rString += FootCode;
            return rString;
        }
    }



